Skip to content

feat(adventure): Add deck import/export and inventory management#10813

Open
emirikol1 wants to merge 4 commits into
Card-Forge:masterfrom
emirikol1:feature/adventure-deck-import-export
Open

feat(adventure): Add deck import/export and inventory management#10813
emirikol1 wants to merge 4 commits into
Card-Forge:masterfrom
emirikol1:feature/adventure-deck-import-export

Conversation

@emirikol1
Copy link
Copy Markdown

Summary

Adds multi-format deck import (Arena, MTGO, native .dck), collection export in Arena format, mark-for-sale workflow, and a fix for Veil of Summer crashing the game.

Deck Import/Export (Adventure Mode)

Console Commands:

  • load deck <path> — Import deck, auto-give missing cards free
  • load deck buy <path> — Import deck, purchase missing cards with gold
  • check deck <path> — Report which cards are missing without importing
  • save deck <path> — Export selected deck as native .dck
  • export collection <path> — Export full collection in Arena format
  • mark sell <path> — Mark listed cards for auto-sell

UI (DeckSelectScene):

  • Import Deck button with 3-mode dialog (free give / buy / check-only)
  • Export Deck, Export Collection, Mark for Sale buttons

Technical Details:

  • Cross-platform file path handling (Unix/Mac/Windows) with ~ expansion
  • Uses existing DeckRecognizer for Arena/MTGO format parsing
  • Auto-finds first empty deck slot; expands slots if all full (up to 99)
  • Mark-for-sale respects cards in use by decks and already-marked cards

Bug Fix: Veil of Summer crash

PlayerFactoryUtil.addStaticAbility() crashed with ArrayIndexOutOfBoundsException when processing Hexproof:Black (2-part format) because it expected a 3-part format. Fixed to use instanceof Hexproof pattern matching and access getValidType() directly, consistent with CardFactoryUtil's approach for card hexproof.

Files Changed

  • forge-gui-mobile/.../util/CardUtil.java — Import/export engine
  • forge-gui-mobile/.../player/AdventurePlayer.java — Slot management helpers
  • forge-gui-mobile/.../stage/ConsoleCommandInterpreter.java — 6 new commands
  • forge-gui-mobile/.../scene/DeckSelectScene.java — 4 new UI buttons
  • forge-game/.../player/PlayerFactoryUtil.java — Hexproof keyword fix

Test Plan

  • Export a deck, re-import in Arena format — cards match
  • Import with missing cards in GIVE mode — cards added to collection
  • Import with all slots full — new slot created automatically
  • Mark for sale respects deck usage limits
  • Cross-platform paths (forward slash, backslash, tilde)
  • Veil of Summer resolves without crash (Hexproof:Black and Hexproof:Blue)
  • Build compiles cleanly on current master (rebased May 30 2026)

Made with Cursor

kinke and others added 2 commits May 30, 2026 20:24
…dventure mode

Adds multi-format deck import (Arena, MTGO, native .dck), collection export
in Arena format, and a mark-for-sale workflow. Available via both console
commands and new UI buttons in the deck selection screen.

Console commands:
- load deck <path>       Import deck, auto-give missing cards
- load deck buy <path>   Import deck, purchase missing cards with gold
- check deck <path>      Report which cards are missing
- save deck <path>       Export selected deck as .dck
- export collection <path>  Export full collection in Arena format
- mark sell <path>       Mark listed cards for auto-sell

UI (DeckSelectScene):
- Import Deck button with 3-mode dialog (free/buy/check-only)
- Export Deck, Export Collection, Mark for Sale buttons

Cross-platform file path handling (Unix/Mac/Windows) with ~ expansion.

Co-authored-by: Cursor <cursoragent@cursor.com>
…raw string parsing

PlayerFactoryUtil.addStaticAbility() crashed with ArrayIndexOutOfBoundsException
when processing "Hexproof:Black" (2-part format) because it expected a 3-part
"Hexproof:<validSource>:<description>" format.

Now uses instanceof Hexproof pattern matching to access getValidType() and
getTitle() directly, consistent with CardFactoryUtil's approach for card hexproof.

Fixes crash when Veil of Summer resolves giving player hexproof from black/blue.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tool4ever tool4ever mentioned this pull request May 31, 2026
@tool4ever
Copy link
Copy Markdown
Contributor

what's the use case, is importing arbitrary decks really part of all normal gameplay...?

@Jetz72
Copy link
Copy Markdown
Contributor

Jetz72 commented Jun 1, 2026

The deck editor already supports importing decklists from the clipboard, though? Not to say there's no room to expand on what's already there, but why an entirely distinct importer?

Cross-platform file path handling (Unix/Mac/Windows) with ~ expansion

How's it work on Android?

kinke and others added 2 commits June 1, 2026 20:59
…icing

Add Adventure-specific dialogs and file picker, format-aware save names,
mark-for-sale rollback, and buy-missing costs matching neutral-rep shops
(getCardPrice × equipment discounts). Share cardShopBuyPrice with RewardScene.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use smaller height and scaled labels so file-op buttons match the compact deck list.

Co-authored-by: Cursor <cursoragent@cursor.com>
@emirikol1
Copy link
Copy Markdown
Author

@tool4ever

You're right that this isn't core "normal" progression gameplay—it's optional tooling for people who want to try lists or manage collection/decks outside the usual loop.

At worst it sits next to the F9 cheat/console side of Adventure (give card, etc.): same "play your way" spirit, but aimed at whole lists from files instead of one card at a time.

It's a single-player adventure mode. There's no ranked play or prizes on the line—if someone doesn't want imports, cheats, or buy-missing, they can ignore the buttons and play straight. If they want to pull a deck from Goldfish/Arena, round-trip a collection through another app, or avoid dozens of console commands, this is for that.

@emirikol1
Copy link
Copy Markdown
Author

@Jetz72

Why a separate importer instead of only clipboard in the deck editor?

Clipboard import in the deck editor is still there for paste-while-editing. It can load a list into the deck you're editing, but it does not add those cards to your Adventure collection—you still don't own them for Adventure play. This adds a file-based path from the deck select screen (and console), plus export collection, export deck, and mark-for-sale from a list file.

The main workflow is bringing in a full list from MTG Goldfish, Arena, or similar into your collection and a deck slot—not adding cards one-by-one in the deck editor (which copy/paste doesn't do for collection ownership), and not running a bunch of F9 console commands (give card, etc.) if you're using cheats. Import mode 2 can buy missing cards for what they'd cost in your world (adventure getCardPrice for that printing × your shop discounts, same basis as a shop at neutral town/shop reputation). Mode 3 grants missing copies free; mode 1 uses only what you already own and reports what's missing.

You can also export your collection (plaintext or Arena-style) to an external library/deck builder, build decks there, and re-import here. Parsing reuses DeckRecognizer and Forge .dck—not a second parser.

Import modes (deck select, in order)

# Label If you own enough (any printing) If you're short
1 Use cards from your collection Deck in first empty slot Missing list only; no deck installed
2 Buy missing cards Deck installed Buy missing at world price, then install
3 Add missing cards free Deck installed Grant missing, then install

Export

Target Formats
Deck .dck, plaintext, Arena, MTGO
Collection Plaintext, Arena-style

Paths / Android

Adventure uses AdventureFilePicker on Forge's FFileChooser. Default folder is home or Downloads on Android. We don't filter by extension. It is not the system document picker; storage permission may be required. ~ expands via user.home where the JVM provides it.

Mark for sale: Pick a deck list; owned cards not in any deck (and not already marked) are flagged for auto-sell, with rollback to restore prior marked counts.

Copy link
Copy Markdown
Contributor

@tool4ever tool4ever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure all plane authors prefer if the intended gameplay experience can get messed up that easily, to me such default offerings kind of imply that the balance might be too screwed up without them 🤔

Tbh I think the original vision was not to reproduce quest mode with walking a map on top but more of a story-driven progression.

So wouldn't it make more sense to isolate such stuff cleanly in a sandbox mode than just "plastering" the GUI with cheat buttons? 🤷‍♂️

Above isn't meant as blocking, I'm mostly an observer on Adventure - though I can't recommend merging 2000+ lines of AI code without lots of manual cleanup...

@Jetz72
Copy link
Copy Markdown
Contributor

Jetz72 commented Jun 2, 2026

Inclined to agree; the options to automatically buy and to automatically grant missing cards completely ignore intended progression and the limited availability of cards. Making them available through anything other than the dev console would suggest to the user that they're part of the intended way to play Adventure.

If we wanted to accommodate people who want to cheat entire custom decks into adventure and don't want to manually add the cards, we may as well just add a cheat command that gives you a full collection and then let people use the regular importer. And if the existing import/export tools don't cover enough formats, it'd make more sense to broaden their functionality rather than implement them all over again.

I'm not sure what the use case for marking the cards in an externally maintained deck list for sale is.

@emirikol1
Copy link
Copy Markdown
Author

Thanks for the comments. Let me think on it a bit. I have found it to be useful and fun, but I do see your points. I too wondered if maybe it should be stashed deeper than it is.

Let me think on it.

Out of curiosity, if it was callable just from the f9 menu would that fit better?

I was on the fence about importing sell lists. That was a final thought and easily droppable. Happy to make adjustments to make it fit better. I do find the deck importer to be a big time saver for how I personally play. (I simply don’t have enough time to play the game purely as ‘intended’.

I suppose alternatively I could build and release as a stand alone editor. I was hoping to make it so others like myself had access to some of the capabilities.

Open to thoughts.

@Jetz72
Copy link
Copy Markdown
Contributor

Jetz72 commented Jun 2, 2026

Out of curiosity, if it was callable just from the f9 menu would that fit better?

Probably better than anywhere else in the application right now, though I think an external editor like you said might be more suitable for something of this scale. The dev console is primarily for quick tweaks and debugging rather than a full-fledged tool for customizing a game experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants